<template>
    <div class="feeddetial">
        <h3 class="top">
            <i class="iconfont icon-fanhui" @click.stop="$router.back()"></i>
        </h3>
        <div class="videobox" v-if="feed">
            <video :src="feed.video.url" controls autoplay v-if="feed.video && feed.video.url"></video>
        </div>
        <div class="video-detial">
            <van-tabs v-model="active" v-if="feed" line-width="20px">
                <van-tab title="简介">
                    <div class="info">
                        <h1>{{feed.title}}</h1>
                    </div>
                    <div class="time" v-if="feed.onlineTime">
                        {{feed.onlineTime|filtime}}
                    </div>
                    <div class="icons">
                        <div class="thums" @click.stop="changecount">
                            <i :class="['iconfont','icon-dianzan1',isgood?'checked':'']"></i>
                            <span>{{feed.upCount}}</span>
                        </div>
                        <div class="thums" @click.stop="active=1">
                            <i class="iconfont icon-pinglun1"></i>
                            <span>{{feed.commentCount}}</span>
                        </div>
                    </div>
                </van-tab>
                <van-tab title="评论" :badge="feed.commentCount">内容 2</van-tab>
            </van-tabs>
        </div>
    </div>
</template>

<script>
export default {
    props:{
        'movieId':{
            type:String,
            default:""
        },
        'feedId':{
                type:String,
                default:""
        }
    },
    data(){
        return{
            feed:[],
            active:0,
            isgood:false
        }
    },
    created(){
        if(this.movieId.length>0){
            this.getMovieDetial();
        }
    },
    methods:{
        async getMovieDetial(){
            let re=await this.axios.get('movie/detail?movieid='+this.movieId);
            let feeds=re.data.feedVideos.feeds;
            feeds.forEach(item => {
                if(item.id===Number(this.feedId)){
                    this.feed=item;
                }
            });
        },
        changecount(){
            this.isgood=!this.isgood;
            let a=this.feed.upCount;
            if(this.isgood){
                a+=1;
            }else{
                a-=1;
            }
            this.feed.upCount=a;
        }
    },
    filters:{
        filtime(time){
            let date=new Date(time);
            let y=date.getFullYear();
            let m=date.getMonth()+1;
            let d=date.getUTCDate();
            m=m>9?m:"0"+m;
            d=d>9?d:'0'+d;
            return y+'-'+m+'-'+d;
        }
    },
}
</script>

<style lang="less">
.feeddetial{
    h3.top{
        width: 100%;
        line-height: 30px;
        position: sticky;
        top: 0;
        left: 0;
        z-index: 2;
        background-color: black;
        color: #fff;
    
        i{
            margin-left: 15px;
        }
    }
}

.videobox{
    width: 100%;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 2;

    video{
        width: 100%;
    }
}

.video-detial{
    .van-info{
        border-radius: 0px;
        background-color: #fff;
        color: red;
        right: -20px;
    }

    .van-tabs__content{
        padding: 16px;
        position: relative;

        &::after{
            content: "";
            width: 100%;
            position: absolute;
            left: 0;
            top: 0;
            border-bottom: 1px solid #eee;
        }
    }

    .info{
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 17px;
        color: #333;
    }

    .time{
        font-size: 13px;
        color: #999;
        padding-top: 15px;
    }

    .icons{
        display: flex;
        justify-content: space-around;
        padding-top: 20px;

        i{
            font-size: 28px;
            color: #8c7e7e;

            &.checked{
                color: red;
            }
        }

        span{
            display: block;
            font-size: 12px;
            color: #666;
        }
    }
}
</style>